package com.sgcc.operate.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.sgcc.common.datascope.annotation.DataScope;
import com.sgcc.operate.domain.OMsgMng;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sgcc.common.log.annotation.Log;
import com.sgcc.common.log.enums.BusinessType;
import com.sgcc.common.security.annotation.PreAuthorize;
import com.sgcc.operate.domain.OPrizeMng;
import com.sgcc.operate.service.IOPrizeMngService;
import com.sgcc.common.core.web.controller.BaseController;
import com.sgcc.common.core.web.domain.AjaxResult;
import com.sgcc.common.core.utils.poi.ExcelUtil;
import com.sgcc.common.core.web.page.TableDataInfo;

/**
 * 奖品管理Controller
 * 
 * @author sgcc
 * @date 2021-03-23
 */
@RestController
@RequestMapping("/prizemng")
public class OPrizeMngController extends BaseController
{
    @Autowired
    private IOPrizeMngService oPrizeMngService;

    /**
     * 查询奖品管理列表
     */
    //@PreAuthorize(hasPermi = "operate:mng:list")
    @GetMapping("/list")
    @DataScope(deptAlias = "o2")
    public TableDataInfo list(OPrizeMng oPrizeMng)
    {
        startPage();
        List<OPrizeMng> list = oPrizeMngService.selectOPrizeMngList(oPrizeMng);
        return getDataTable(list);
    }

    /**
     * 导出奖品管理列表
     */
    //@PreAuthorize(hasPermi = "operate:mng:export")
    @Log(title = "奖品管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @DataScope(deptAlias = "o2")
    public void export(HttpServletResponse response, OPrizeMng oPrizeMng) throws IOException
    {
        List<OPrizeMng> list = oPrizeMngService.selectOPrizeMngList(oPrizeMng);
        ExcelUtil<OPrizeMng> util = new ExcelUtil<OPrizeMng>(OPrizeMng.class);
        util.exportExcel(response, list, "mng");
    }

    /**
     * 获取奖品管理详细信息
     */
    //@PreAuthorize(hasPermi = "operate:mng:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(oPrizeMngService.selectOPrizeMngById(id));
    }

    /**
     * 新增奖品管理
     */
    //@PreAuthorize(hasPermi = "operate:mng:add")
    @Log(title = "奖品管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OPrizeMng oPrizeMng)
    {
        return toAjax(oPrizeMngService.insertOPrizeMng(oPrizeMng));
    }

    /**
     * 修改奖品管理
     */
    //@PreAuthorize(hasPermi = "operate:mng:edit")
    @Log(title = "奖品管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OPrizeMng oPrizeMng)
    {
        return toAjax(oPrizeMngService.updateOPrizeMng(oPrizeMng));
    }

    /**
     * 删除奖品管理
     */
    //@PreAuthorize(hasPermi = "operate:mng:remove")
    @Log(title = "奖品管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(oPrizeMngService.deleteOPrizeMngByIds(ids));
    }

    /**
     * 查询群组管理列表
     */
    //@PreAuthorize(hasPermi = "operate:mng:list")
    @GetMapping("/optionselect")
    @DataScope(deptAlias = "o2")
    public AjaxResult optionselect(OPrizeMng oMsgMng)
    {
        return AjaxResult.success(oPrizeMngService.selectOPrizeMngList(oMsgMng));
    }

}
